package com.crazymakercircle.dhptester.starter;

import com.crazymakercircle.dhptester.distributed.TaskExecutor;
import com.crazymakercircle.dhptester.distributed.WorkerNode;
import com.crazymakercircle.util.ThreadUtil;
import com.crazymakercircle.zk.SnowflakeIdGenerator;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
//自动加载配置信息
@EnableAutoConfiguration
//使包路径下带有@Value的注解自动注入
//使包路径下带有@Autowired的类可以自动注入
@ComponentScan("com.crazymakercircle.dhptester")
@SpringBootApplication
@Slf4j
public class ClientApplication
{


    /**
     * @param args
     */
    public static void main(String[] args)
    {

        // 启动并初始化 Spring 环境及其各 Spring 组件
        ApplicationContext context = SpringApplication.run(ClientApplication.class, args);

        String workId = WorkerNode.getSingleton().getId();
        log.info("节点已经启动，workId = " + workId);

        SnowflakeIdGenerator.setWorkerId(workId);
        SnowflakeIdGenerator.getSingleton();
        TaskExecutor.getSingleton().startMoniter();

        //  jvm选项    -Xms2G -Xmx8G
        //  命令 参数   soultest1 10 1000000 cdh1
        //  第一个参数为 soultest1， 启动百万连接 netty 灵魂测试客户端

        ThreadUtil.sleepSeconds(Integer.MAX_VALUE);

    }


}
